package no.sachmuld.methodcombination.api.reflection;

import no.sachmuld.methodcombination.api.reflection.component.SimpleMethodCombination;

/**
*
*/
public class Min<T extends Comparable> extends SimpleMethodCombination<Object, T, T> {

    private T min;

    @Override
    protected boolean handleSingleResult(T singleResult) {
        if (min == null) {
            min = singleResult;
        } else {
            int compare = singleResult.compareTo(min);
            if (compare < 0) {
                min = singleResult;
            }
        }
        return true;
    }

    @Override
    protected T combinedResult() {
        return min;
    }
}
